/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2018
 */

package com.bm.console.business.impl;

import com.bm.console.business.WebExpoApplyService;
import com.bm.console.pojo.WebExpoApply;
import com.bm.console.pojo.mapper.WebExpoApplyMapper;
import com.sys.object.common.page.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class WebExpoApplyServiceImpl implements WebExpoApplyService {

    @Autowired
    WebExpoApplyMapper webExpoApplyMapper;

    @Override
    public PageBean queryPageList(WebExpoApply entity, PageBean page) throws Exception {
        int rowCount = webExpoApplyMapper.selectByPageCount(entity);
        page.setRowCount(rowCount);
        entity.setOffset(page.getStartRow());
        entity.setLimit(page.getPerpage());
        page.setList(webExpoApplyMapper.selectByPage(entity));
        return page;
    }

    public WebExpoApply queryByPrimaryKey(Integer id) throws Exception {
        return webExpoApplyMapper.selectByPrimaryKey(id);
    }

    public int saveOrUpdate(WebExpoApply entity) throws Exception {
        if (entity.getId() != null && entity.getId() > 0) {
            entity.setUpdateTime(new Date());
            if (entity.getIsView()) {
                entity.setViewTime(new Date());
            }
            return this.webExpoApplyMapper.updateByPrimaryKeySelective(entity);
        }
        entity.setCreateTime(new Date());
        return this.webExpoApplyMapper.insert(entity);
    }

    public int remove(Integer id) throws Exception {
        return this.webExpoApplyMapper.deleteByPrimaryKey(id);
    }

    public int delete(Integer id) throws Exception {
        return this.webExpoApplyMapper.deleteByPrimaryKey(id);
    }

    public int updateStatus(WebExpoApply entity) throws Exception {
        return this.webExpoApplyMapper.updateByPrimaryKeySelective(entity);
    }

    public int updateStatus(String status, String[] ids)
            throws Exception {

        return 0;
    }


}
